package cn.mw.cmdb.service.impl;

import cn.mw.cmdb.param.FunctionModuleEnum;
import cn.mw.cmdb.service.FunctionalModuleService;

import java.util.HashMap;
import java.util.Map;

public class FunctionalModuleManage {

    private static Map<FunctionModuleEnum, FunctionalModuleService> map = null;

    public static FunctionalModuleService getFunctionalModule(FunctionModuleEnum functionModuleEnum) {
        if (null == map) {
            synchronized (FunctionalModuleManage.class) {
                if (null == map) {
                    doInit();
                }
            }
        }
        FunctionalModuleService moduleService = map.get(functionModuleEnum);

        return moduleService;
    }

    private static void doInit() {
        map = new HashMap<>();

        MonitorModuleServiceImpl monitorModuleService = new MonitorModuleServiceImpl();
        // 其他实现类的初始化在这里put
        map.put(FunctionModuleEnum.enableMonitor, monitorModuleService);

    }

}
